package com.igeek.compus.study.system;

import lombok.Data;

@Data
public class R<T> {
    private Integer code;
    private String msg;
    private T data;
    private Integer count;

    private R() {
    }

    public static R ok() {
        R r = new R();
        r.setCode(Constants.SUCCESS_CODE);
        r.setMsg(Constants.SUCCESS_MSG);
        return r;
    }

    public static R error() {
        R r = new R();
        r.setCode(Constants.ERROR_CODE);
        r.setMsg(Constants.ERROR_MSG);
        return r;
    }

    public R code(Integer code) {
        this.setCode(code);
        return this;
    }

    public R data(T data) {
        this.data = data;
        return this;
    }

}
